<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>

<blockquote class="layui-elem-quote"><{$action}></blockquote>

<form class="layui-form layui-form-pane" method="post">
	<input type="hidden" name="id" value="<{$wangdian_info['id']|default:'0'}>" />
	<div class="layui-form-item">
		<label class="layui-form-label">网点名称</label>
		<div class="layui-input-block">
			<input type="text" name="name" value="<{$wangdian_info.name|default:''}>" lay-verify="required" autocomplete="off" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">URL</label>
			<div class="layui-input-block">
				<input type="text" name="url" value="<{$wangdian_info.url|default:''}>" autocomplete="off" class="layui-input">
			</div>
	</div>

	<div class="layui-form-item">
        <label class="layui-form-label">学校地址</label>
        <div class="layui-input-inline">
            <select name="province_code" id="province" lay-filter="province" lay-verify="required">
                <option value="">请选择省</option>
                <{foreach from=$province_list item=item }>
                <option value="<{$item['area_code']}>" <{if isset($wangdian_info) && $wangdian_info['province_code']==$item['area_code'] }>selected<{/if}> ><{$item['area_name']}></option>
                <{/foreach}>
            </select>
        </div>
       
        <div class="layui-input-inline">
            <select name="city_code" id="city" lay-filter="city" lay-verify="required">
                <option value="">请选择市</option>
                <{if isset($city_list)}>
                <{foreach from=$city_list item=item }>
                <option value="<{$item['area_code']}>" <{if isset($wangdian_info) && $wangdian_info['city_code']==$item['area_code'] }>selected<{/if}> ><{$item['area_name']}></option>
                <{/foreach}>
                <{/if}>
            </select>
        </div>

        <div class="layui-input-inline">
            <select name="area_code" id="district" lay-filter="district" lay-verify="required">
                <option value="">请选择区</option>
                <{if isset($area_list)}>
                <{foreach from=$area_list item=item }>
                <option value="<{$item['area_code']}>" <{if isset($wangdian_info) && $wangdian_info['area_code']==$item['area_code'] }>selected<{/if}> ><{$item['area_name']}></option>
                <{/foreach}>
                <{/if}>
            </select>
        </div>
        <input type="hidden" name="province_name" id="province_name" value="<{$wangdian_info['province_name']|default:''}>"/>
        <input type="hidden" name="city_name" id="city_name" value="<{$wangdian_info['city_name']|default:''}>"/>
        <input type="hidden" name="area_name" id="area_name" value="<{$wangdian_info['area_name']|default:''}>"/>
    </div>

	<div class="layui-form-item">
		<label class="layui-form-label">详细地址</label>
		<div class="layui-input-block">
			<input type="text" name="address" value="<{$wangdian_info.address|default:''}>" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">是否启用</label>
		<div class="layui-input-block">
				<{assign var="status" value=$wangdian_info.status|default:"1"}>
				<input type="checkbox" <{if $status == 1}> checked <{/if}> name="status" lay-skin="switch" lay-filter="switchTest" value="1" >
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">排序</label>
			<div class="layui-input-block">
				<input type="text" name="sort" value="<{$wangdian_info.sort|default:'0'}>" autocomplete="off" class="layui-input">
			</div>
	</div>

	<div class="layui-form-item layui-form-text">
		<input type="hidden" id="token" value="<{'VIMG'|get_qiniu_token}>" />
		<label class="layui-form-label">LOGO</label>
		<div class="layui-input-block" style="margin-top: 5px;">
			<div id="uploader2" class="upload_box" style="float:left; width:420px;">
				<div class="queueList">
					<div id="dndArea2" class="placeholder dndArea">
						<div id="filePicker2" class="filePicker"></div>
						<p>或将照片拖到这里，最多可上传<script>document.write(fileNumLimit);</script>张图片</p>
					</div>
				</div>
				<div class="statusBar" style="display:none;">
					<div class="progress">
						<span class="text">0%</span>
						<span class="percentage"></span>
					</div><div class="info"></div>
					<div class="btns">
						<div id="filePickerBut2" class="filePickerBut"></div><div class="uploadBtn">开始上传</div>
					</div>
				</div>
				<div class="upload_img_input" input_name='logo'></div>
			</div>
			<{if isset($wangdian_info['logo']) AND $wangdian_info['logo'] != ''}>
				<div class="layui-inline" style="float:left;"><img src="<{$wangdian_info['logo']}>" style="max-height:175px;"/></div>
			<{/if}>
		</div>
	</div>


	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">网点介绍</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea layui-hide editor" name="introduce" lay-verify="content" id="editor"><{$wangdian_info.introduce|default:""}></textarea>
		</div>
	</div>	

	<div class="layui-input-block">
		<button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>


<{include file="public_html/footer.html"}>
<script>
    layui.use(['laydate', 'form'], function(){
        var laydate = layui.laydate, form = layui.form();

        form.on('select(province)',function(data){
            var ii = layer.load();
            var province_code = data.value;
            $("#province_name").val($("#province option:selected").text())
            $("#city_name").val('');
            $("#area_name").val('');
            $("#city").html('<option value="">请选择城市</option>');
            $("#district").html('<option value="">请选择区域</option>');
            form.render('select');
            $.ajax({
                type: "GET",
                url: "/area/get_area_by_parent/"+province_code,
                dataType:"json",
                success: function(result){
                    var html ='';
                    $.each(result, function(i, obj) {
                        html += '<option value="'+obj.area_code+'">'+obj.area_name+'</option>';
                    });
                    $("#city").append(html);
                    form.render('select');
                    layer.close(ii);
                }
            });
        });

        form.on('select(city)',function(data){
            var ii = layer.load();
            var city_code = data.value;
            $("#city_name").val($("#city option:selected").text())
            $("#area_name").val('');
            $("#district").html('<option value="">请选择区域</option>');
            form.render('select');
            $.ajax({
                type: "GET",
                url: "/area/get_area_by_parent/"+city_code,
                dataType:"json",
                success: function(result){
                    var html ='';
                    $.each(result, function(i, obj) {
                        html += '<option value="'+obj.area_code+'">'+obj.area_name+'</option>';
                    });
                    $("#district").append(html);
                    form.render('select');
                    layer.close(ii);
                }
            });
        });

        form.on('select(district)',function(data){
            $("#area_name").val($("#district option:selected").text())
        });
    });
</script>